﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using SD.Database.Classes;
using DBAccess;
using System.Collections.Generic;

namespace SD.Database
{
    public partial class StoredProcedures
    {
        public static bool CheckIfSystemExists(int x, int y)
        {
            if (DAL.GetInstance().GetInt("Select count(*) From Systems Where X = @param0 and Y = @param1", new List<object>() { x, y }) == 0)
                return false;
            else
                return true;
        }

        public static void CreateSystem(int x, int y, string name)
        {
            DAL.GetInstance().InsertData("Insert into Systems (SystemName, X, Y) Values(@param0, @param1, @param2)", new List<object>() { name, x, y });
            InsertLog(DateTime.Now, "CreateSystem", x + " " + y + " " + name);
        }

        public static void CreatePlanets(int sId, int number)
        {
            for (int i = 1; i <= number; i++)
            {
                DAL.GetInstance().InsertData("Insert into Planets (PlanetId,SystemID) Values(@param0, @param1)", new List<object>() { i, sId });
            }
        }
    };
}